const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin')
const WebpackMerge = require('webpack-merge')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const {
    CleanWebpackPlugin
} = require('clean-webpack-plugin')
const baseConfig = require('./webpack.base.config')
const dist_dir = path.join(__dirname, 'dist_pro')

module.exports = WebpackMerge(baseConfig, {
    mode: 'production',
    output: {
        filename: '[hash:6]-[name]-pro.js',
        path: dist_dir,
    },
    plugins: [
        // new ExtractTextWebpackPlugin('style.css'),
        new htmlWebpackPlugin({
            template: './src/index.html',
            title: '生产版本',
        }),
        new MiniCssExtractPlugin({
            filename: '[hash:6]-style-pro.css',
            chunkFilename: '[id]-style-pro.css',
        }),
        new CleanWebpackPlugin({
            cleanOnceBeforeBuildPatterns: [
                dist_dir,
            ],
        }),
    ],
})